<template>
  <div class="addgoods">
    <el-card>
      <template>
        <el-upload class="upload-demo" action="http://127.0.0.1:8888/api/private/v1/upload" 
        :on-preview="handlePreview" :headers="headerObj"  :on-remove="handleRemove" :file-list="fileList" list-type="picture">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
        </el-upload>
      </template>
      <!-- 分页 start -->

      <!-- 分页 end -->
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return { fileList: [] ,
       headerObj: {
        Authorization: window.sessionStorage.getItem('token')
      },}
  },
  mounted() {},
  methods: {
    handleRemove(file, fileList) {
      console.log('MMMMM')
      console.log(file, fileList)
      const filepath = file.response.dta.tmp_path
    },
    handlePreview(file) {
      console.log('上传1')
      console.log(file)
    },
   
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`)
    }
    /* beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    }*/
  }
}
</script>
